Format.js ➔ CSVFormatter   A
last analyzed

Complexity

Conditions 4

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 14
c 0
b 0
f 0
rs 10
cc 4
1
import { format } from 'winston';
2
3
export default function CSVFormatter(fields, options = {}) {
4
    const delim = options.delimiter || ';';
5
    const missed = options.missed || '';
6
7
    return format.printf(logObject => {
8
        const data = fields.map(key => {
9
            const value = logObject[key];
10
11
            return value === undefined ? missed : value;
12
        });
13
14
        return data.join(delim);
15
    });
16
}
17